﻿#include<iostream>
#include<Windows.h>
#include <conio.h>
#include <memory>
#include "startPage.h"
#include "color_print.h"
using namespace std;
void startPage::loadPage() {
	system("cls");
	system("color 06");
	string s1("自盘古开天以来，山河零乱，世界分为正魔两派，长久以来相互制约。神隐之地，最初只是一个名不见转的小宗门，在旷世奇才南宫离的威势和庇护下，一步步崛起，威震寰宇......");
	//int in;
	for (int i = 0;i < s1.length();i++) {
		cout << s1[i];
		if (!_kbhit()) {
			Sleep(25);
		}
	}
	cout << endl;
	system("pause");
	system("cls");
	s1 = "然而，实力抵不过人心的险恶，纵使他剑压星空，仍不免被同门背叛，小人陷害，在天地动荡中陨落......";
	for (int i = 0;i < s1.length();i++) {
		cout << s1[i];
		if (!_kbhit()) {
			Sleep(25);
		}
	}
	cout << endl;
	system("pause");
	system("cls");
	s1 = "天道不忍一世英才就此消散，特使其灵魂留滞世间，时机得当之时重返神隐之地......";
	for (int i = 0;i < s1.length();i++) {
		cout << s1[i];
		if (!_kbhit()) {
			Sleep(25);
		}
	}
	cout << endl;
	system("pause");
	system("cls");

	
	COLOR_PRINT("请输入你的名字:", 2);

	string name;
	cin >> ws;
	cin >> name;
	cout << "请选择你要降生的属性" << endl;
	cout << "1、天生神力(攻击力突出)" << endl;
	cout << "2、商业巨擘(金钱更多)" << endl;
	cout << "3.皮糙肉厚(更多血量)" << endl;
	cout << "4.潜力股(更容易升级)" << endl;
	cout << "5.创世神(dddd)" << endl;
	int in;
	cin >> ws;
		while (true) {
			if (cin >> in) {
				if (in >= 1 && in <= 5) {
					break;
				}
				else if (in == 6) {
					cin >> ws;
					cin >> in;
				}
				else {
					cin >> ws;
					in = 6;
					cout << "输入不合法！" << endl;
					cin >> in;
					cin >> ws;
				}
			}
			else {
				//cin >> ws;
				cin.clear();
				char ch;
				cin.get(ch);
				cout << "输入不合法！" << endl;
				//cin >> in;
			}
		}
	
	
	
	switch (in) {
	case 1: {
		Hero hero(50, 30, name, 0, 100, 1, 100, 100, 100);
		system("cls");
		vector<vector<string>> say;
		init_sayContent(say);
		unique_ptr<Page> fp = make_unique<roomPage>(QING, "清水镇", "白胡子老头", 0, say[QING]);
		load(*fp, hero);
		break;
	}
	case 2: {
		Hero hero(100, 10, name, 0, 100, 1, 100, 100, 1000);
		system("cls");
		vector<vector<string>> say;
		init_sayContent(say);
		unique_ptr<Page> fp = make_unique<roomPage>(QING, "清水镇", "白胡子老头", 0, say[QING]);
		load(*fp, hero);
		break;
	}
	case 3: {
		Hero hero(300, 10, name, 0, 100, 1, 100, 100, 100);
		system("cls");
		vector<vector<string>> say;
		init_sayContent(say);
		unique_ptr<Page> fp = make_unique<roomPage>(QING, "清水镇", "白胡子老头", 0, say[QING]);
		load(*fp, hero);
		break;
	}
	case 4: {
		Hero hero(80, 10, name, 0, 20, 1, 100, 100, 100);
		system("cls");
		vector<vector<string>> say;
		init_sayContent(say);
		unique_ptr<Page> fp = make_unique<roomPage>(QING, "清水镇", "白胡子老头", 0, say[QING]);
		load(*fp, hero);
		break;
	}
	case 5: {
		Hero hero(1000, 50, name, 0, 20, 1, 500, 500, 100000);
		system("cls");
		vector<vector<string>> say;
		init_sayContent(say);
		unique_ptr<Page> fp = make_unique<roomPage>(QING, "清水镇", "白胡子老头", 0, say[QING]);
		load(*fp, hero);
		break;
	}
	}
	//Hero hero(100, 10, name, 0, 100, 1, 100, 100, 100000);//测试商店用
	
}

int startPage::get_position() const {

	return 0;
}